from sale.utils import db


class UserInfo(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(32), default='', comment='用户名字')
    phone = db.Column(db.String(32), default='', comment='用户手机')
    password = db.Column(db.String(32), default='', comment='用户密码')


class VerifyCode(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    phone = db.Column(db.String(32), default='', comment='用户手机')
    verify_code = db.Column(db.String(32), default='', comment='验证码')
    status = db.Column(db.Integer, default=0, comment='使用状态')
    create_time = db.Column(db.DateTime, default=db.func.now(), comment='创建时间')


class Phone(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    phone = db.Column(db.String(32), default='', comment='充值手机号码')


class PackageInfo(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    original_price = db.Column(db.DECIMAL(10, 2), default='', comment='原价格')
    discount_price = db.Column(db.DECIMAL(10, 2), default='', comment='现价格')


class OrderInfo(db.Model):
    __tablename__ = 'order_info'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, default=0, comment='用户ID')
    user_phone = db.Column(db.String(32), default='', comment='用户手机号')
    package_id = db.Column(db.Integer, default=0, comment='套餐ID')
    face_value = db.Column(db.String(32), default='', comment='面额')
    pay_amount = db.Column(db.DECIMAL(10, 2), default='', comment='支付金额')
    order_no = db.Column(db.String(32), default='', comment='订单号')
    pay_no = db.Column(db.String(32), default='', comment='支付单号')
    goods_desc = db.Column(db.String(64), default='', comment='商品详情')
    pay_time = db.Column(db.DateTime, default=db.func.now(), comment='支付时间')
    recharge_time = db.Column(db.DateTime, default=db.func.now(), comment='成交时间')
    order_status = db.Column(db.String(32), default='INIT', comment='订单状态')
    create_time = db.Column(db.DateTime, default=db.func.now(), comment='创建时间')
    update_time = db.Column(db.DateTime, default=db.func.now(), onupdate=db.func.now(), comment='更新时间')


